﻿'********************************************************************************
'*
'*      ダイシング　フォーム
'*
'*      File Name : frmStartCompleteDicing.vb S31
'*      Title     : ダイシング着工/完了画面
'*      機能    　：ダイシング工程
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ -----------------------------------------------
' V1.0.0   2016/09/14 S.Yu         新規作成
' V2.0.0   2017/05/15 F.Gotou      蘇州対応
' V3.0.0   2017/12/12 M.Sagawa     北京対応
'********************************************************************************

Imports System.Text

Public Class frmStartCompleteDicing

    'bSite取得値ブレードのカテゴリ名
    Private Const BLADECATEGORY As String = "DCBL"

    'エラー時表示文言
    Private Const ERROR_TITLE_BLADE = "BLADE"

    ' 外部画面呼び出しTAG
    Private Const EXEC_PG_TAG_BLADE As String = "DB_BLADE"

    'イベント設定
    Public Overrides Sub SetHandler()

        '再読み込み
        AddHandler btnRefresh.Click, AddressOf btnRefresh_Click
        '補充ボタン
        AddHandler btnFrameAdd.Click, AddressOf btnFrameAdd_Click

        AddHandler btnBarCode1.Click, AddressOf btnMsRackNo1_Click '2018/2/22 佐川 ラックNo入力動作を統一
        AddHandler btnBarCode2.Click, AddressOf btnMsRackNo2_Click '2018/2/22 佐川 ラックNo入力動作を統一
        AddHandler txt2103.Click, AddressOf rackInputFocus
        AddHandler lbl2103.Click, AddressOf rackInputFocus
        AddHandler txt2103.KeyPress, AddressOf beforeRackNo_KeyPress

        AddHandler txt1103.KeyPress, AddressOf beforeRackNo_KeyPress
        AddHandler txt1103.Click, AddressOf rackInputFocus
        AddHandler lbl1103.Click, AddressOf rackInputFocus

        pkgFLG = 1 'LC中使用
    End Sub



    '照合結果設定
    Public Overrides Sub SetPassScore()
        ' 入力内容は2つ。設備タブ「ブレード1,2」.着工料盒号
        PASS_SCORE = 3
        ReDim m_iScore(PASS_SCORE - 1)
        ' 設備タブ「ブレード1,2」は着工チェックあり
        m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
        m_fColl = True
    End Sub

    '照合結果をクリアする
    Public Overrides Sub InitualizeCollData()
        ' 設備タブ「ブレード1,2」は着工チェックあり
        m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
        m_fColl = True
    End Sub

    'Lot Noでデータベースからデータを取得する
    Public Overrides Sub GetDataByIcTag()

        '入力欄の初期化
        inputDataClear()

        'ICタグのデータで画面を設定する
        SetFromTag()
        'ロット部のセット
        setGridViewLot()

        If String.IsNullOrEmpty(IcTag.szUID) Then
            IcTag = LastTag
        End If

        '製造条件取得
        setJyokenData()

        '現物型式
        setDetailData()


        If IcTag.Status = TagProcessStatus.Ready Then
            '設備部の値を製造条件から設定
            For Each dr In dtJyokenData.Rows
                If dr(KOMOKUNAME).Equals(lbl0100.Tag) Then
                    'ブレード1の設定
                    lbl0102.Text = DBNullTOblank(dr(KOMOKUDATA))
                ElseIf dr(KOMOKUNAME).Equals(lbl0200.Tag) Then
                    'ブレード2の設定
                    lbl0202.Text = DBNullTOblank(dr(KOMOKUDATA)) 'UPD MIAO 2018/10/18
                End If
            Next

            'ブレードチェック処理
            If Not checkBlade() Then
                Exit Sub
            End If

            '2021 Dicing自动着工，让用户手工输入料盒号
            '<<2018/1/31 佐川 キャリア交換対応
            'txt1103.Text = IcTag.container1  
            '>>2018/1/31 佐川 キャリア交換対応

            '情報タブは前工程からデータ取得
            getPreInfoTabData()
        ElseIf IcTag.Status = TagProcessStatus.Processing Then
            '設備・特殊部に現物型式をセット
            For Each dr In dtDetailData.Rows
                If dr("MNF_CND_TAG").Equals(lbl0100.Tag) Then
                    'ブレード1の設定
                    '製造条件
                    lbl0102.Text = DBNullTOblank(dr("MNF_CONDITION")) 'UPD MIAO 2018/11/1
                    '現物型式
                    txt1203.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                    '材料ロット
                    txt1204.Text = DBNullTOblank(dr("MATERIAL_LOT")) 'UPD MIAO 2018/11/1
                ElseIf dr("MNF_CND_TAG").Equals(lbl0200.Tag) Then
                    'ブレード2の設定
                    '製造条件
                    lbl0202.Text = DBNullTOblank(dr("MNF_CONDITION")) 'UPD MIAO 2018/11/1
                    '現物型式
                    txt1303.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                    '材料ロット
                    txt1304.Text = DBNullTOblank(dr("MATERIAL_LOT")) 'UPD MIAO 2018/11/1
                ElseIf dr("MNF_CND_TAG").Equals(lbl1100.Tag) Then
                    'ウェハケースNo
                    txt1103.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1

                ElseIf dr("MNF_CND_TAG").Equals(lbl1101.Tag) Then
                    'ウェハケースNo
                    txt2103.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                End If
            Next
        Else
            ' 画面の初期設定側でエラー処理をするのでここでは無処理
        End If

        getHeadData()

        With m_dtMat
            If .Rows.Count > 0 Then
                '着完日時
                DisplayDate()
            Else
                If m_dtMat.Columns.Count > 0 Then
                    .Rows.Add()
                Else
                    .Columns.Add("BEGIN_TIME")
                    .Rows.Add()
                End If
            End If
        End With

    End Sub

    '画面データ保存（着工時）
    Public Overrides Function SaveEquipMat(ByRef szBeginTime As DateTime) As Boolean
        If saveDetail(BEGIN) < 0 Then
            Return False
        Else
            Return True
        End If

        Return True
    End Function

    '画面データ保存（製造完成）
    Public Overrides Function SaveCompleteInfo(Optional ByVal status As ProcessStatus = ProcessStatus.ManufComplete) As Integer
        dtDBUpd.Clear()
        Return saveDetail(COMPLETE)
    End Function

    '画面データ保存（計上完成）
    Public Overrides Function SaveTotalInfo() As Integer
        dtDBUpd.Clear()
        Return saveDetail(TOTAL)
    End Function

    Public Overrides Function EndCheck() As Boolean
        If Not checkBlade() Then
            'ブレードの再チェックを行う。
            btnTotalComp.Enabled = False
            Return False
        End If
        '>>20180302 大賀 GroupKey入力時ウェハ枚数入力
        If Not CheckInputWaferNum() Then
            Return False
        End If
        '<<20180302 大賀 GroupKey入力時ウェハ枚数入力
        If txt2103.Text = "" Then
            setCheckInfo(getMsgStr("MSG00002", lbl1100.Text))
            Return False
        End If
        If txt1103.Text.Trim <> txt2103.Text.Trim Then
            setCheckInfo(getMsgStr("MSG00089", lbl1100.Text))

            Return False
        End If
        Return True
    End Function

    Private Function saveDetail(ByVal type As String) As Integer

        ' ロットタブのデータセット
        setLotData()

        Dim rowsCnt As Integer = dtDBUpd.Rows.Count
        Dim addIndex As Integer = 0

        ' 設備タブのデータセット
        ' ブレードZ1
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl0100.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CONDITION) = lbl0102.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1203.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT) = txt1204.Text
        addIndex += 1

        ' ブレードZ2
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CONDITION) = lbl0202.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1303.Text
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MATERIAL_LOT) = txt1304.Text
        addIndex += 1

        '情報部
        'ウェハケースNo--完工料盒
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1100.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt1103.Text
        addIndex += 1
        'ウェハケースNo--着工料盒
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG) = lbl1101.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG_FLG) = 0
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_SEQ) = 1
        dtDBUpd.Rows(rowsCnt + addIndex)(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL) = txt2103.Text
        addIndex += 1

        Dim cnt As Integer

        cnt = m_cEquipMat.SaveDetail(lotNo, IcTag.szProcsCD, type,
                                  m_szTable, dtDBUpd, m_dtHeader,
                                  m_cIdohyo.EquipInfo.szEquipNo, serverTime)
        Return cnt
    End Function

    '入力項目の初期化
    Private Sub inputDataClear()

        'LOTタブのクリア
        clearActualModel()

        'ブレードZ1
        lbl0102.Text = String.Empty
        lbl0102.BackColor = NORMAL_INIT_COLOR
        txt1203.Text = String.Empty
        txt1203.BackColor = NORMAL_INIT_COLOR
        lbl1203.BackColor = NORMAL_INIT_COLOR
        txt1204.Text = String.Empty
        txt1204.BackColor = NORMAL_INIT_COLOR
        lbl1204.BackColor = NORMAL_INIT_COLOR

        'ブレードZ2
        lbl0202.Text = String.Empty
        lbl0202.BackColor = NORMAL_INIT_COLOR
        txt1303.Text = String.Empty
        txt1303.BackColor = NORMAL_INIT_COLOR
        lbl1303.BackColor = NORMAL_INIT_COLOR
        txt1304.Text = String.Empty
        txt1304.BackColor = NORMAL_INIT_COLOR
        lbl1304.BackColor = NORMAL_INIT_COLOR

        'ウェハケースNo
        txt1103.Text = String.Empty
        txt1103.BackColor = BARCODE_INIT_COLOR
        lbl1103.BackColor = BARCODE_INIT_COLOR

        '完工料盒
        txt2103.Text = String.Empty
        txt2103.BackColor = BARCODE_INIT_COLOR
        lbl2103.BackColor = BARCODE_INIT_COLOR

        '補充ボタン非活性
        btnFrameAdd.Enabled = False

        '開始作業者No
        txtOptNoStt.Text = String.Empty
        '終了作業者No
        txtOptNoEnd.Text = String.Empty
        If AUTO_MANUAL_BTN = TYPE_AUTO Then
            setAutoScreen(True)
        Else
            setAutoScreen(False)
        End If
    End Sub

    Public Overrides Sub ConfScreenItem()
        If txtLotNo.TextLength > 0 Then
            If IcTag.Status = TagProcessStatus.Ready Then
                '着工待ち   
                btnBarCode1.Enabled = True
                btnBarCode2.Enabled = True
                '受入MSラックNo1
                txt2103.BackColor = BARCODE_INIT_COLOR
                lbl2103.BackColor = BARCODE_INIT_COLOR

                txt1103.BackColor = BARCODE_INIT_COLOR
                lbl1103.BackColor = BARCODE_INIT_COLOR

            Else
                '着工中
                btnBarCode1.Enabled = False
                btnBarCode2.Enabled = False

                '受入MSラックNo1
                txt2103.BackColor = NORMAL_INIT_COLOR
                lbl2103.BackColor = NORMAL_INIT_COLOR

                '完工料盒
                txt1103.BackColor = NORMAL_INIT_COLOR
                lbl1103.BackColor = NORMAL_INIT_COLOR
            End If

            '補充ボタン非活性
            btnFrameAdd.Enabled = True
        End If

    End Sub



    '再読込ボタン押下
    Protected Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not checkBlade() Then
            btnTotalComp.Enabled = False
        End If
    End Sub

    'ブレード B-Siteチェック
    Private Function checkBlade() As Boolean
        Dim result As Boolean = True
        Dim isSetupError = False
        'ブレードZ1
        txt1203.Text = String.Empty
        txt1203.BackColor = NORMAL_INIT_COLOR
        lbl1203.BackColor = NORMAL_INIT_COLOR
        txt1204.Text = String.Empty
        txt1204.BackColor = NORMAL_INIT_COLOR
        lbl1204.BackColor = NORMAL_INIT_COLOR

        'ブレードZ2
        txt1303.Text = String.Empty
        txt1303.BackColor = NORMAL_INIT_COLOR
        lbl1303.BackColor = NORMAL_INIT_COLOR
        txt1304.Text = String.Empty
        txt1304.BackColor = NORMAL_INIT_COLOR
        lbl1304.BackColor = NORMAL_INIT_COLOR

        'B-Site ViewMachineService
        Dim clientProcCd = GetBsiteClientString()
        Dim outMachine = getViewLotService(clientProcCd)
        Dim MaterialList = getMachineMaterialListByCategory(outMachine, BLADECATEGORY)
        Dim getDataList = MaterialList.Where(Function(x) x.Type IsNot Nothing And x.OriginalLot IsNot Nothing).ToList
        If getDataList.Count = 0 Then
            ' B-Siteから取得できない
            setCheckInfo(getMsgStr("MSG00101", ERROR_TITLE_BLADE))
            txt1203.BackColor = ERROR_INIT_COLOR
            lbl1203.BackColor = ERROR_INIT_COLOR
            txt1203.Text = String.Empty
            m_iScore(CInt(txt1203.Tag.ToString) - 1) = 0
            txt1303.BackColor = ERROR_INIT_COLOR
            lbl1303.BackColor = ERROR_INIT_COLOR
            txt1303.Text = String.Empty
            m_iScore(CInt(txt1303.Tag.ToString) - 1) = 0
            Return False
        End If

        'ブレード1 B-siteチェック
        If Not checkBladeDetail(lbl0102.Text, lbl0202.Text, txt1203, txt1303, txt1204, getDataList) Then
            '現物型式の背景色変更
            txt1203.BackColor = ERROR_INIT_COLOR
            '材料ロットの背景色変更
            lbl1203.BackColor = ERROR_INIT_COLOR
            m_iScore(CInt(txt1203.Tag.ToString) - 1) = 0
            result = False
        End If

        'ブレード2 B-siteチェック
        If Not checkBladeDetail(lbl0202.Text, lbl0102.Text, txt1303, txt1203, txt1304, getDataList) Then
            '現物型式の背景色変更
            txt1303.BackColor = ERROR_INIT_COLOR
            '材料ロットの背景色変更
            lbl1303.BackColor = ERROR_INIT_COLOR
            m_iScore(CInt(txt1303.Tag.ToString) - 1) = 0
            result = False
        End If

        If result Then
            '現物型式の背景色変更
            txt1203.BackColor = NORMAL_INIT_COLOR
            lbl1203.BackColor = NORMAL_INIT_COLOR
            '現物型式の背景色変更
            txt1303.BackColor = NORMAL_INIT_COLOR
            lbl1303.BackColor = NORMAL_INIT_COLOR
            m_iScore(CInt(txt1203.Tag.ToString) - 1) = 1
            m_iScore(CInt(txt1303.Tag.ToString) - 1) = 1
        Else
            ' checkBladeDetailがFalseの場合は一括表示
            setCheckInfo(getMsgStr("MSG10030", ERROR_TITLE_BLADE, makeViewMachineTypeString(getDataList)))
        End If

        Return result
    End Function

    'ブレード 比較処理
    'param blade 自ブレード製造条件
    'param otherBlade 別ブレード製造条件
    'param txtItemType 自ブレード現物型式
    'param otherTxtItemType 別ブレード現物型式
    'param txtItemLot 自ブレード材料ロット
    'param outMachine bSiteから取得データ
    Private Function checkBladeDetail(ByVal blade As String, ByVal otherBlade As String, ByRef txtItemType As TextBox, ByRef otherTxtItemType As TextBox, ByRef txtItemLot As TextBox, ByVal outMachine As List(Of InSiteWebService.Machine_Material)) As Boolean

        '製造条件が空の場合はチェックしない
        If String.IsNullOrEmpty(blade) Then
            Return True
        End If
        Dim getData = outMachine.FirstOrDefault(Function(x) x.Type = blade)
        If getData Is Nothing Then
            ' 製造条件と一致しない
            Return False
        End If
        '現物型式の値設定
        txtItemType.Text = getData.Type.Trim
        '材料ロットの値設定
        txtItemLot.Text = getData.OriginalLot.Trim

        Return True
    End Function

    ' 情報タブの前工程データ取得
    Protected Sub getPreInfoTabData()

        Dim Pre_Proc_Table As String = ""
        Dim Pre_Proc_Code As String = ""
        ' 前工程取得
        Dim dtPreProc = m_cData.GetPreProcCode(IcTag.szLotNo, lblProcessCD.Text) 'UPD 苗 2018/1/25
        If dtPreProc.Rows.Count > 0 Then
            ' 前工程の結果テーブル名設定
            Pre_Proc_Table = dtPreProc.Rows(0)("PROCTABLE")
            ' 前工程の工程コード設定
            Pre_Proc_Code = dtPreProc.Rows(0)("PREPROC")

            dtDetailData = New DataTable

            ' 着工前の場合は、前工程のデータを取得する。
            If IcTag.Status = TagProcessStatus.Ready Then
                ' 前工程の計上データ取得
                '>>苗 GROUP ID 修正 2018/1/12
                dtDetailData = m_cEquipMat.GetDetailResult(IcTag.szLotNo, Pre_Proc_Code, TOTAL, Pre_Proc_Table) '苗 GROUP ID 修正 2018/1/12
                '<<苗 GROUP ID 修正 2018/1/12
                '<<2018/1/31 佐川 キャリア交換対応
                'For Each dr In dtDetailData.Rows
                '    '取得データが存在した場合は値を設定する。
                '    If dr(DB_WORK_RESULT_PHYSICALNAME_MNF_CND_TAG).Equals(lbl1100.Tag) Then
                '        'ウェハケースNoに値を設定
                '        'txt1103.Text = dr(DB_WORK_RESULT_PHYSICALNAME_ACTUAL_MODEL)
                '    End If
                'Next
                '>>2018/1/31 佐川 キャリア交換対応
            End If
        End If
    End Sub

    '補充ボタン押下
    Protected Sub btnFrameAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        '外部EXEを呼び出す
        Dim strRetStatus As String = Execute_Command(lblProcessCD.Text, EXEC_PG_TAG_BLADE, txtDiffLot.Text, g_EQUIP_NO, "", UserNo)
        '戻り値による処理は未定のため、現在は未実装
        If strRetStatus = "0" Then
            If Not checkBlade() Then
                btnTotalComp.Enabled = False
            End If
        Else
            setCheckInfo(getMsgStr("MSG10009", strRetStatus))
        End If
    End Sub

    '計上完成正常時の画面初期化
    Protected Overrides Sub initializForm()
        MyBase.initializForm()
        inputDataClear()
    End Sub

    Public Overrides Sub updateRackInfo()
        Dim rackNo As New ArrayList
        Dim dbLot As New clsDbLotDefect
        If txt1103.Text <> "" Then
            rackNo.Add(txt1103.Text)
        End If

        dbLot.DelInsRackInfo(IcTag.szDifLotNo, rackNo)
    End Sub
    Overrides Sub setProcessingLot()
        Dim InProcLot As String
        Dim waferLotDT As DataTable
        InProcLot = getProcessingLot()
        If InProcLot <> "" Then

            waferLotDT = m_cData.GetWbLotData(InProcLot)
            If IsNothing(waferLotDT) = False AndAlso waferLotDT.Rows.Count > 0 Then
                txtDiffLot.Text = waferLotDT(0)("WAFER_LOTNO")
                txtDiffLot_KeyPress(txtDiffLot, New KeyPressEventArgs(vbCr))
            End If

        End If
    End Sub

    '------------2021 PQC对应--------------
    Overrides Function chkMatChanged() As Boolean
        Dim pqc As New clsPQCCheck
        Dim katamei As String = ""
        Dim matlot As String = ""
        Dim rtn As Boolean = False
        Dim rtn2 As Boolean = False

        pqc.selectPQC(lblEquipID.Text, katamei, matlot)

        If katamei = "" And txt1203.Text & "/" & txt1303.Text <> "" And txt1204.Text & "/" & txt1304.Text <> "" Then
            pqc.insertPQC(lblEquipID.Text, txt1203.Text & "/" & txt1303.Text, txt1204.Text & "/" & txt1304.Text)
            rtn = False
        End If
        If katamei <> "" Then

            If (katamei.Contains(txt1203.Text) And katamei.Contains(txt1303.Text)) And (matlot.Contains(txt1204.Text) And matlot.Contains(txt1304.Text)) Then
                rtn = False
            Else
                If txt1203.Text & "/" & txt1303.Text <> "" And txt1204.Text & "/" & txt1304.Text <> "" Then
                    pqc.updatePQC(lblEquipID.Text, txt1203.Text & "/" & txt1303.Text, txt1204.Text & "/" & txt1304.Text)
                    setChangeForPQC(EXEC_PG_TAG_BLADE)
                End If

                rtn = True
            End If
        End If

        '-----------------车品WaferLot PQC检查------------------------
        If m_cLotInfo.isCar(txtLotNo.Text) = True Then
            If pqc.isSameWaferLot(g_CURRENT_EQUIP_ID, txtDiffLot.Text) = True Then
                rtn2 = False
            Else
                pqc.updateCarWaferLot(g_CURRENT_EQUIP_ID, txtDiffLot.Text)
                setChangeForPQC("WAFER_LOT")
                rtn2 = True
            End If
        End If
        Return (rtn Or rtn2)
    End Function


    '------------2021 PQC对应--------------

    '----------2021 DC、TC、LTF自动着工对应0619 begin
    Protected Overrides Sub setBeforeRackNo(Optional inputRackNo As String = "")

        If CUSTOMIZES_DC_TC_LTF_AUTO = True Then

            If IsNothing(IcTag.szLotNo) = False Then
                If IcTag.container1 <> "" Then
                    txt2103.Text = IcTag.container1
                    m_iScore(2) = PASS_SCORE_CHECKED
                End If
            End If

        End If
    End Sub
    Protected Overrides Function setAfterRackNo(receiveData As receiveCommandData) As Boolean

        If CUSTOMIZES_DC_TC_LTF_AUTO = True Then

            If receiveData.UrackNoList.Count = 0 Then
                Return False
            End If
            '完工MS料盒设置
            If IsNothing(receiveData.UrackNoList(0)) = False Then
                txt1103.Text = receiveData.UrackNoList(0)
            End If
        End If
        Return True

    End Function

    Overrides Function getLCPackage() As String
        If CUSTOMIZES_DC_TC_LTF_AUTO = True Then

            If IsNothing(dtJyokenData) Then
                Return MyBase.getLCPackage()
            End If

            Dim WAFERNAME As String = ""
            Dim mobjInParam As New DFlowService.InProcessCondition
            Dim mobjOutParam As New DFlowService.OutProcessCondition
            Dim Txn As New DFlowService.MFlowService

            Dim InHeader As New DFlowService.InHeader
            mobjInParam.Header = InHeader
            mobjInParam.Header.Client = "416301" ' 切替システムのCLIENTです
            dtJyokenData.DefaultView.RowFilter = "KOTEI = 'LOTINFO' and KOMOKUNAME = 'PRODUCT NAME'"
            mobjInParam.ProductName = dtJyokenData.DefaultView.Item(0)("KOMOKUDATA").ToString

            Dim pcData() As DFlowService.ProcessConditionData
            '③の取得
            mobjOutParam = Txn.ProcessConditionService_List(mobjInParam) '查询
            Dim outHeader As New DFlowService.OutHeader()
            If (mobjOutParam.Header.Status = "SUCCESS") Then

                pcData = mobjOutParam.ProcessConditionList

                For i As Integer = 0 To pcData.Length - 1

                    If pcData(i).Rudf = "RUDF239" Then
                        WAFERNAME = pcData(i).Value
                        Exit For
                    End If

                Next

            End If
            Return WAFERNAME
        Else
            MyBase.getLCPackage()
        End If
    End Function
    Protected Overrides Function getShape() As String
        Return lblShape.Text
    End Function
    Protected Sub btnMsRackNo1_Click(ByVal sender As Object, ByVal e As EventArgs)
        txt2103.Text = String.Empty
        txt2103.Enabled = True
        txt2103.Focus()
        txt2103.SelectAll()
        txt2103.BackColor = FOCUS_INIT_COLOR
        lbl2103.BackColor = FOCUS_INIT_COLOR
    End Sub
    Protected Sub btnMsRackNo2_Click(ByVal sender As Object, ByVal e As EventArgs)
        txt1103.Text = String.Empty
        txt1103.Enabled = True
        txt1103.Focus()
        txt1103.SelectAll()
        txt1103.BackColor = FOCUS_INIT_COLOR
        lbl1103.BackColor = FOCUS_INIT_COLOR
    End Sub

    Public Overrides Sub rackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        '未着工のみ選択可能にする
        If IcTag.Status = TagProcessStatus.Ready Then
            MyBase.rackInputFocus(sender, e)
        End If
    End Sub
    Protected Overrides Sub setAutoScreen(mode As Boolean)

        Dim setColor As Color = NORMAL_INIT_COLOR
        Dim setEnabled As Boolean = Not (mode)

        '完工后，是否清空画面，清空后ictag也被清空（手动时为true,自动时为false)
        initializForm_FLG = setEnabled

        If mode = True Then
            setColor = NORMAL_INIT_COLOR
        Else
            setColor = BUTTON_INIT_COLOR
        End If
        txt2103.Enabled = setEnabled
        txt1103.Enabled = setEnabled
        btnBarCode1.Enabled = setEnabled
        btnBarCode2.Enabled = setEnabled

        lbl2103.BackColor = setColor
        txt2103.BackColor = setColor

        lbl1103.BackColor = setColor
        txt1103.BackColor = setColor

    End Sub

    Private Sub beforeRackNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        '改行コードが入力された場合は、受入MSラックNoのチェックを行う
        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox)
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10

            If beforeRackNoCheck(sender, e) Then
                txtData.Enabled = False
                '>>2018/2/6 佐川 RSB確認結果一覧No32
                '受入MSラックNo1が前工程と一致しているかつ
                '着工前の場合は受入MSラックNo2を入力可能にしフォーカスを合わせる
                If IcTag.Status = TagProcessStatus.Ready Then
                    '<<2018/2/6 佐川 RSB確認結果一覧No32
                    txt2103.Enabled = True
                    txt2103.Focus()
                    txt2103.BackColor = FOCUS_INIT_COLOR
                    lbl2103.BackColor = FOCUS_INIT_COLOR
                End If
            End If
        End If
    End Sub

    Private Function beforeRackNoCheck(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim idx As Integer = 2 ' CInt(lblData.Name.Substring(3, 2))
        Dim procCheckResult As Boolean = False

        '着工料盒号check

        '空白チェック
        If txt2103.Text.Equals("") Then
            setCheckInfo(getMsgStr("MSG00020", lbl1101.Text))
            checkColor(sender, False, lbl2103.Name)
            m_iScore(idx) = 0
            Return False
        End If

        '>>桁数チェック
        If Not txt2103.Text.Equals("") Then
            ' ラックNoの桁数チェック
            If Not isCheckCaseLength(txt2103, MS_RACK_CASE_NO_LENGTH, lbl2103) Then
                m_iScore(idx) = PASS_SCORE_WAIT_CHECK
                Return False
            End If
        End If

        '前工程のデータと比較
        '>>2018/1/31 佐川 キャリア交換対応
        If txt2103.Text.Equals(IcTag.container1) Then
            procCheckResult = True
        End If

        '前工程データに一致しない場合
        If Not procCheckResult Then
            setCheckInfo(getMsgStr("MSG00052", lbl1101.Text))
            checkColor(txt2103, False, lbl2103.Name)
            txt2103.SelectAll() '2018/2/22 佐川 ラックNo入力動作を統一
            m_iScore(idx) = 0
            Return False
        End If
        checkColor(txt2103, True, lbl2103.Name)

        '完工料盒号check
        '空白チェック
        If txt1103.Text.Equals("") Then
            setCheckInfo(getMsgStr("MSG00020", lbl1100.Text))
            checkColor(txt1103, False, lbl1103.Name)
            m_iScore(idx) = 0
            Return False
        End If

        '>>桁数チェック
        If Not txt1103.Text.Equals("") Then
            ' ラックNoの桁数チェック
            If Not isCheckCaseLength(txt1103, MS_RACK_CASE_NO_LENGTH, lbl1103) Then
                m_iScore(idx) = PASS_SCORE_WAIT_CHECK
                Return False
            End If
        End If

        '>>着完工料盒是否一致
        If txt1103.Text.Equals(txt2103.Text) = False Then
            setCheckInfo(getMsgStr("MSG00131", lbl1101.Text, lbl1100.Text))
            checkColor(txt1103, False, lbl1103.Name)
            txt1103.SelectAll() '2018/2/22 佐川 ラックNo入力動作を統一
            m_iScore(idx) = 0
            Return False
        End If

        checkColor(txt1103, True, lbl1103.Name)

        m_iScore(idx) = 1
        CheckCollScore()
        Return True
    End Function

    Overrides Sub setinitializForm_FLG()
        initializForm_FLG = True
    End Sub

    '----------2021 DC、TC、LTF自动着工对应0619 end
End Class


